#!/usr/bin/python
# -*- coding: utf-8 -*-
import utlis


class GushiWen(object):
    def __init__(self, data):
        self.id = data['id']
        self.idnew = utlis.toString(data['idnew'])
        self.nameStr = utlis.toString(data['nameStr'])
        self.author = utlis.toString(data['author'])
        self.chaodai = utlis.toString(data['chaodai'])
        content = utlis.toString(data['cont'])
        content = content.replace("'", "\\\'")
        content = content.replace('"', '\\\"')
        self.cont = content
        self.axing = data['axing']
        self.bxing = data['bxing']
        self.cxing = data['cxing']
        self.dxing = data['dxing']
        self.exing = data['exing']
        self.type = utlis.toString(data['type'])
        self.tag = utlis.toString(data['tag'])
        self.langsongAuthor = utlis.toString(data['langsongAuthor'])
        self.langsongAuthorPY = utlis.toString(data['langsongAuthorPY'])
        self.yizhu = utlis.toString(data['yizhu'])
        self.yizhuAuthor = utlis.toString(data['yizhuAuthor'])
        cankao = utlis.toString(data['yizhuCankao'])
        cankao = cankao.replace("'", "\\\'")
        cankao = cankao.replace('"', '\\\"')
        self.yizhuCankao = cankao
        self.yizhuYuanchuang = data['yizhuYuanchuang']
        self.yizhuIspass = data['yizhuIspass']
        self.shangIspass = data['shangIspass']
        self.beijingIspass = data['beijingIspass']
        self.pinglunCount = data['pinglunCount']

    def obj_2_json(self):
        return {
            'id': self.id,
            'idnew': self.idnew,
            'nameStr': self.nameStr,
            'cont': self.cont
        }
